using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using ScreenTest.Players;
using Microsoft.Xna.Framework;
using ScreenTest.Constants;

namespace ScreenTest.Items
{
    class Rocket : BaseItem
    {
        Texture2D rocketTexture;
        const int ROCKET_SIZE = 12;

        public Rocket()
        {
            
            isActive = true;
            size = ROCKET_SIZE;
        }

        public override void Load(ContentManager content)
        {
            rocketTexture = content.Load<Texture2D>(@"Content\rocket");
        }

        public override void Draw(GraphicsDevice device, SpriteBatch spriteBatch)
        {
            if (isActive)
                spriteBatch.Draw(rocketTexture, new Rectangle((int)position.X - ROCKET_SIZE, (int)position.Y - ROCKET_SIZE, ROCKET_SIZE, ROCKET_SIZE), null, Color.White, 0f, new Vector2(ROCKET_SIZE / 2, ROCKET_SIZE / 2), SpriteEffects.None, 0f);
            //if (isActive)
            //    spriteBatch.Draw(rocketTexture, new Rectangle((int)position.X - ROCKET_SIZE, (int)position.Y - ROCKET_SIZE, ROCKET_SIZE, ROCKET_SIZE), null, Color.White);
        }

        //public void PickUpHealth(Player player)
        //{
        //    int playerHealth = player.Health;

        //    playerHealth += healthAmount;
        //    if (playerHealth > 100)
        //    {
        //        playerHealth = 100;
        //    }

        //    player.Health = playerHealth;

        //    isActive = false;
        //}

        public void PickUpRockets(Player player)
        {
            int playerRockets = player.Rockets;
            playerRockets += 5;

            if (playerRockets > GameConstants.MAX_ROCKETS)
            {
                playerRockets = GameConstants.MAX_ROCKETS;
            }

            player.Rockets = playerRockets;

            isActive = false;
        }

        public override void Touches(Player player)
        {
            if (isActive)
            {
                if (player.GetBoundingBox().Intersects(GetBoundingBox()))
                {
                    PickUpRockets(player);
                }
            }
        }

        public override void Respawn()
        {
            respawnTime = GameConstants.RESPAWN_ROCKET;
            base.Respawn();
        }
    }
}
